package com.simplefan.meta.engine.jdbc.mysql;

import com.simplefan.meta.engine.jdbc.AbstractResultPagination;

public class MysqlResultPagination extends AbstractResultPagination {

  /**
   * realized by using keywords "minus".
   * 
   * @see com.simplefan.meta.engine.jdbc.ResultPagination#addPaginationSql(String, int, int)
   */
  public String addPaginationSql(String sql, int start, int maxCount) {
    StringBuffer buffer = new StringBuffer();

    buffer.append(sql);
    buffer.append(" limit ").append(start).append(",").append(start+maxCount+1);
    return buffer.toString();
  }

  /**
   * realized by using keywords "minus".
   * 
   * @see com.simplefan.meta.engine.jdbc.ResultPagination#addPaginationSql(String, String, int, int)
   */
  public String addPaginationSql(String sql, String orderBy, int start, int maxCount) {
    StringBuffer buffer = new StringBuffer();

    buffer.append(sql);
    buffer.append(" " + orderBy);
    buffer.append(" limit ").append(start).append(",").append(start+maxCount+1);
    return buffer.toString();
  }
}
